package com.kalman.common;
/**
 * @author kalman03
 */
public class SafeConvert {

	public static String toString(Object o,String _default){
		if(o != null)return o.toString();
		return _default;
	}
	
	public static String toString(Object o){
		if(o != null)return o.toString();
		return "";
	}
	
	public static int toInt(Object o,int _default){
		try {
			String _int = toString(o);
			return Integer.parseInt(_int);
		} catch (Exception e) {
			// ignore
		}
		return _default;
	}
	

	
	public static long toLong(Object o,long _default){
		try {
			String _long = toString(o);
			return Long.parseLong(_long);
		} catch (Exception e) {
			// ignore
		}
		return _default;
	}
	
}
